/*
                  SnakeEngine Class Definition
*/

#ifndef WORMENGINE_H
#define WORMENGINE_H

#define MOVEMENTINTERVAL 200

#include "SDL/SDL.h"
#include <vector>
#include <iostream>
#include <string>

#include "Interface.h"
#include "Player.h"
#include "Food.h"
#include "NetworkDefinitions.h"
#include "Point.h"
#include "Mapping/Map.h"
#include "Camera.h"
#include "ConfigFile.h"
#include "Timer.h"
#include "KeyBindings.h"
#include "AI.h"
#include "SummaryInfo.h"
#include "StringUtil.h"

enum GameType { GAMETYPE_NONE = -1, GAMETYPE_SCORE, GAMETYPE_KILL };

using namespace std;

class SnakeEngine
{
    public:
        ~SnakeEngine() {}

        static int GameSetup(const string& strMap, const int& iStartSize, const GameType& NewGametype, const int& iNewFoodCount,
                            const int& iNewScoreToWin);

        static int StartGame();

        static int AddPlayer(const string& strName, const bool& bIsCPU);
        static int RemovePlayer(const int& id);

        static void Update(Chatbox *cbxMessages);
        static void HandlePlayerCollisions(const int& id);

        static void Draw(SDL_Surface *surface);
        static InterfaceType HandleInput(const SDL_Event& event);

        static void Quit();

        static void setLocalPlayer(const string& strNewLocalPlayer);
        static int getLocalPlayer();

        static int getNumPlayers();

        static int HandleKeyDown(string strKeyName, Uint16 UNICODEvalue);

        static vector<string> getScoreboardInfo();

        static bool getNeedScoreUpdate();
        static void setNeedScoreUpdate(const bool& bNewVal);

        static int getScoreToWin();

    private:
        SnakeEngine() {}

        static vector<Player*> Players;
        static vector<Food*> FoodObjects;

        static bool bGameRunning;
        static bool bGameFinished;
        static bool bCPUOnlyGame;
        static GameType gameType;

        static Map currentMap;
        static SDL_Surface *World;
        static int iLocalPlayer;

        static Timer tmrFrame;
        static int iTimePassed;

        static int iCurrentKeyPress;

        static int iSnakeStartSize;
        static int iFoodCount;
        static int iNumCPUs;
        static int iScoreToWin;
        static int iWinner;

        static int iCurrentDirection;

        static AI engineAI;

        static bool bNeedScoreUpdate;

        static vector<string> Messages;
        static vector<string> KillMessages;

        static void FoodEaten(int id);
        static void CheckVictory(const int& id);
};

#endif
